# import requests
# url="https://blog.huixiangwuyou.com"
# url2="https://blog.huixiangwuyou.com/webview/img/mysql.jpeg"
# resp = requests.get(url)
# resp.encoding='utf-8'
# print(resp.text) # 获取 html
# print(resp.content) # 若是爬取是图片获取 二进制
#
# with open("load.jpeg","wb") as fp:
#     fp.write(resp.content)



from openpyxl import load_workbook,Workbook
cj=[
    ['姓名','语文','数学','英语'],
    ['李世民', '100', '75', '59'],
    ['刘备', '90', '65', '95']
]
# wb = Workbook()
# sheet = wb.create_sheet('班级学生成绩单')
# for item in cj:
#     sheet.append(item)
#
# wb.save('abs.xlsx')

# # 打开工作簿
# wb = load_workbook('abs.xlsx')
# # 获取活动工作表
# sheet = wb['Sheet']
# # 获取单元格的值
# cell_value = sheet['A1'].value
# print('cell_value',cell_value)
# # 设置单元格的值
# sheet['C2'] = 'C,Handsome boy!'
# # 保存工作簿
# wb.save('abs.xlsx')






# import pdfplumber
#
# with pdfplumber.open('git.pdf') as fp:
#     for i in fp.pages:
#         print(i.extract_text()) # extract_text()获取内容
#         print(f'第---{i.page_number}页')



# import numpy as np
# import matplotlib.pyplot as plt
# # 读取图片
# n1=plt.imread('load.jpeg')
# print(n1)
# # 三维数组，最高维度表示图像高，次维度表示图像宽，最低表示图像[R，G，B]颜色
# plt.imshow(n1)
# # 写一个灰度公式
# n2=np.array([0.299,0.597,0.114])
#
# x=np.dot(n1,n2)
# # 传入数组显示灰度
# plt.imshow(x,cmap='gray')
# plt.show()




import pandas as pd
import matplotlib.pyplot as plt
# # 读取excel文件
# df=pd.read_excel('abs.xlsx')
# # 解决中文乱码问题
# plt.rcParams['font.sans-serif']=['SimHei']
# # 设置画布大小
# plt.figure(figsize=(10,6))
# print(df['班级学生成绩单'])
# labels=df['班级学生成绩单']
# y=df['姓名']
#
# # 绘制饼图
# plt.pie(y,labels=labels,autopct='%1.1f%%',startangle=98)
# # 设置x，y刻度
# plt.axis('equal')
# plt.title('班级学生成绩单')
#
# plt.show()


# 模拟班级成绩数据
data = {
    '姓名': ['张三', '李四', '王五', '赵六', '孙七'],
    '成绩': [85, 90, 78, 92, 88]
}

# 创建 DataFrame
df = pd.DataFrame(data)
# 解决中文乱码问题
plt.rcParams['font.sans-serif']=['SimHei']
# 设置图片清晰度
plt.rcParams['figure.dpi'] = 100

# 绘制柱形图
plt.bar(df['姓名'], df['成绩'])

# 添加标题和标签
plt.title('班级成绩柱形图')
plt.xlabel('姓名')
plt.xticks(rotation=45)
plt.ylabel('成绩')

# 显示图形
plt.show()












